/*
 * Copyright (c) 2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef OHOS_NWEB_WEB_NET_ERROR_LIST_H
#define OHOS_NWEB_WEB_NET_ERROR_LIST_H

namespace OHOS {
namespace NWeb {
constexpr int32_t NET_OK = 0;
constexpr int32_t ERR_IO_PENDING = -1;
constexpr int32_t ERR_FAILED = -2;
constexpr int32_t ERR_ABORTED = -3;
constexpr int32_t ERR_INVALID_ARGUMENT = -4;
constexpr int32_t ERR_INVALID_HANDLE = -5;
constexpr int32_t ERR_FILE_NOT_FOUND = -6;
constexpr int32_t ERR_TIMED_OUT = -7;
constexpr int32_t ERR_FILE_TOO_LARGE = -8;
constexpr int32_t ERR_UNEXPECTED = -9;
constexpr int32_t ERR_ACCESS_DENIED = -10;
constexpr int32_t ERR_NOT_IMPLEMENTED = -11;
constexpr int32_t ERR_INSUFFICIENT_RESOURCES = -12;
constexpr int32_t ERR_OUT_OF_MEMORY = -13;
constexpr int32_t ERR_UPLOAD_FILE_CHANGED = -14;
constexpr int32_t ERR_SOCKET_NOT_CONNECTED = -15;
constexpr int32_t ERR_FILE_EXISTS = -16;
constexpr int32_t ERR_FILE_PATH_TOO_LONG = -17;
constexpr int32_t ERR_FILE_NO_SPACE = -18;
constexpr int32_t ERR_FILE_VIRUS_INFECTED = -19;
constexpr int32_t ERR_BLOCKED_BY_CLIENT = -20;
constexpr int32_t ERR_NETWORK_CHANGED = -21;
constexpr int32_t ERR_BLOCKED_BY_ADMINISTRATOR = -22;
constexpr int32_t ERR_SOCKET_CONNECTED = -23;
constexpr int32_t ERR_UPLOAD_STREAM_REWIND_NOT_SUPPORTED = -25;
constexpr int32_t ERR_CONTEXT_SHUT_DOWN = -26;
constexpr int32_t ERR_BLOCKED_BY_RESPONSE = -27;
constexpr int32_t ERR_CLEARTEXT_NOT_PERMITTED = -29;
constexpr int32_t ERR_BLOCKED_BY_CSP = -30;
constexpr int32_t ERR_H2_OR_QUIC_REQUIRED = -31;
constexpr int32_t ERR_BLOCKED_BY_ORB = -32;
constexpr int32_t ERR_CONNECTION_CLOSED = -100;
constexpr int32_t ERR_CONNECTION_RESET = -101;
constexpr int32_t ERR_CONNECTION_REFUSED = -102;
constexpr int32_t ERR_CONNECTION_ABORTED = -103;
constexpr int32_t ERR_CONNECTION_FAILED = -104;
constexpr int32_t ERR_NAME_NOT_RESOLVED = -105;
constexpr int32_t ERR_INTERNET_DISCONNECTED = -106;
constexpr int32_t ERR_SSL_PROTOCOL_ERROR = -107;
constexpr int32_t ERR_ADDRESS_INVALID = -108;
constexpr int32_t ERR_ADDRESS_UNREACHABLE = -109;
constexpr int32_t ERR_SSL_CLIENT_AUTH_CERT_NEEDED = -110;
constexpr int32_t ERR_TUNNEL_CONNECTION_FAILED = -111;
constexpr int32_t ERR_NO_SSL_VERSIONS_ENABLED = -112;
constexpr int32_t ERR_SSL_VERSION_OR_CIPHER_MISMATCH = -113;
constexpr int32_t ERR_SSL_RENEGOTIATION_REQUESTED = -114;
constexpr int32_t ERR_PROXY_AUTH_UNSUPPORTED = -115;
constexpr int32_t ERR_BAD_SSL_CLIENT_AUTH_CERT = -117;
constexpr int32_t ERR_CONNECTION_TIMED_OUT = -118;
constexpr int32_t ERR_HOST_RESOLVER_QUEUE_TOO_LARGE = -119;
constexpr int32_t ERR_SOCKS_CONNECTION_FAILED = -120;
constexpr int32_t ERR_SOCKS_CONNECTION_HOST_UNREACHABLE = -121;
constexpr int32_t ERR_ALPN_NEGOTIATION_FAILED = -122;
constexpr int32_t ERR_SSL_NO_RENEGOTIATION = -123;
constexpr int32_t ERR_WINSOCK_UNEXPECTED_WRITTEN_BYTES = -124;
constexpr int32_t ERR_SSL_DECOMPRESSION_FAILURE_ALERT = -125;
constexpr int32_t ERR_SSL_BAD_RECORD_MAC_ALERT = -126;
constexpr int32_t ERR_PROXY_AUTH_REQUESTED = -127;
constexpr int32_t ERR_PROXY_CONNECTION_FAILED = -130;
constexpr int32_t ERR_MANDATORY_PROXY_CONFIGURATION_FAILED = -131;
constexpr int32_t ERR_PRECONNECT_MAX_SOCKET_LIMIT = -133;
constexpr int32_t ERR_SSL_CLIENT_AUTH_PRIVATE_KEY_ACCESS_DENIED = -134;
constexpr int32_t ERR_SSL_CLIENT_AUTH_CERT_NO_PRIVATE_KEY = -135;
constexpr int32_t ERR_PROXY_CERTIFICATE_INVALID = -136;
constexpr int32_t ERR_NAME_RESOLUTION_FAILED = -137;
constexpr int32_t ERR_NETWORK_ACCESS_DENIED = -138;
constexpr int32_t ERR_TEMPORARILY_THROTTLED = -139;
constexpr int32_t ERR_HTTPS_PROXY_TUNNEL_RESPONSE_REDIRECT = -140;
constexpr int32_t ERR_SSL_CLIENT_AUTH_SIGNATURE_FAILED = -141;
constexpr int32_t ERR_MSG_TOO_BIG = -142;
constexpr int32_t ERR_WS_PROTOCOL_ERROR = -145;
constexpr int32_t ERR_ADDRESS_IN_USE = -147;
constexpr int32_t ERR_SSL_HANDSHAKE_NOT_COMPLETED = -148;
constexpr int32_t ERR_SSL_BAD_PEER_PUBLIC_KEY = -149;
constexpr int32_t ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN = -150;
constexpr int32_t ERR_CLIENT_AUTH_CERT_TYPE_UNSUPPORTED = -151;
constexpr int32_t ERR_SSL_DECRYPT_ERROR_ALERT = -153;
constexpr int32_t ERR_WS_THROTTLE_QUEUE_TOO_LARGE = -154;
constexpr int32_t ERR_SSL_SERVER_CERT_CHANGED = -156;
constexpr int32_t ERR_SSL_UNRECOGNIZED_NAME_ALERT = -159;
constexpr int32_t ERR_SOCKET_SET_RECEIVE_BUFFER_SIZE_ERROR = -160;
constexpr int32_t ERR_SOCKET_SET_SEND_BUFFER_SIZE_ERROR = -161;
constexpr int32_t ERR_SOCKET_RECEIVE_BUFFER_SIZE_UNCHANGEABLE = -162;
constexpr int32_t ERR_SOCKET_SEND_BUFFER_SIZE_UNCHANGEABLE = -163;
constexpr int32_t ERR_SSL_CLIENT_AUTH_CERT_BAD_FORMAT = -164;
constexpr int32_t ERR_ICANN_NAME_COLLISION = -166;
constexpr int32_t ERR_SSL_SERVER_CERT_BAD_FORMAT = -167;
constexpr int32_t ERR_CT_STH_PARSING_FAILED = -168;
constexpr int32_t ERR_CT_STH_INCOMPLETE = -169;
constexpr int32_t ERR_UNABLE_TO_REUSE_CONNECTION_FOR_PROXY_AUTH = -170;
constexpr int32_t ERR_CT_CONSISTENCY_PROOF_PARSING_FAILED = -171;
constexpr int32_t ERR_SSL_OBSOLETE_CIPHER = -172;
constexpr int32_t ERR_WS_UPGRADE = -173;
constexpr int32_t ERR_READ_IF_READY_NOT_IMPLEMENTED = -174;
constexpr int32_t ERR_NO_BUFFER_SPACE = -176;
constexpr int32_t ERR_SSL_CLIENT_AUTH_NO_COMMON_ALGORITHMS = -177;
constexpr int32_t ERR_EARLY_DATA_REJECTED = -178;
constexpr int32_t ERR_WRONG_VERSION_ON_EARLY_DATA = -179;
constexpr int32_t ERR_TLS13_DOWNGRADE_DETECTED = -180;
constexpr int32_t ERR_SSL_KEY_USAGE_INCOMPATIBLE = -181;
constexpr int32_t ERR_INVALID_ECH_CONFIG_LIST = -182;
constexpr int32_t ERR_ECH_NOT_NEGOTIATED = -183;
constexpr int32_t ERR_ECH_FALLBACK_CERTIFICATE_INVALID = -184;
constexpr int32_t ERR_CERT_COMMON_NAME_INVALID = -200;
constexpr int32_t ERR_CERT_DATE_INVALID = -201;
constexpr int32_t ERR_CERT_AUTHORITY_INVALID = -202;
constexpr int32_t ERR_CERT_CONTAINS_ERRORS = -203;
constexpr int32_t ERR_CERT_NO_REVOCATION_MECHANISM = -204;
constexpr int32_t ERR_CERT_UNABLE_TO_CHECK_REVOCATION = -205;
constexpr int32_t ERR_CERT_REVOKED = -206;
constexpr int32_t ERR_CERT_INVALID = -207;
constexpr int32_t ERR_CERT_WEAK_SIGNATURE_ALGORITHM = -208;
constexpr int32_t ERR_CERT_NON_UNIQUE_NAME = -210;
constexpr int32_t ERR_CERT_WEAK_KEY = -211;
constexpr int32_t ERR_CERT_NAME_CONSTRAINT_VIOLATION = -212;
constexpr int32_t ERR_CERT_VALIDITY_TOO_LONG = -213;
constexpr int32_t ERR_CERTIFICATE_TRANSPARENCY_REQUIRED = -214;
constexpr int32_t ERR_CERT_SYMANTEC_LEGACY = -215;
constexpr int32_t ERR_CERT_KNOWN_INTERCEPTION_BLOCKED = -217;
constexpr int32_t ERR_SSL_OBSOLETE_VERSION_OR_CIPHER = -218;
constexpr int32_t ERR_CERT_END = -219;
constexpr int32_t ERR_INVALID_URL = -300;
constexpr int32_t ERR_DISALLOWED_URL_SCHEME = -301;
constexpr int32_t ERR_UNKNOWN_URL_SCHEME = -302;
constexpr int32_t ERR_INVALID_REDIRECT = -303;
constexpr int32_t ERR_TOO_MANY_REDIRECTS = -310;
constexpr int32_t ERR_UNSAFE_REDIRECT = -311;
constexpr int32_t ERR_UNSAFE_PORT = -312;
constexpr int32_t ERR_INVALID_RESPONSE = -320;
constexpr int32_t ERR_INVALID_CHUNKED_ENCODING = -321;
constexpr int32_t ERR_METHOD_UNSUPPORTED = -322;
constexpr int32_t ERR_UNEXPECTED_PROXY_AUTH = -323;
constexpr int32_t ERR_EMPTY_RESPONSE = -324;
constexpr int32_t ERR_RESPONSE_HEADERS_TOO_BIG = -325;
constexpr int32_t ERR_PAC_SCRIPT_FAILED = -327;
constexpr int32_t ERR_REQUEST_RANGE_NOT_SATISFIABLE = -328;
constexpr int32_t ERR_MALFORMED_IDENTITY = -329;
constexpr int32_t ERR_CONTENT_DECODING_FAILED = -330;
constexpr int32_t ERR_NETWORK_IO_SUSPENDED = -331;
constexpr int32_t ERR_SYN_REPLY_NOT_RECEIVED = -332;
constexpr int32_t ERR_ENCODING_CONVERSION_FAILED = -333;
constexpr int32_t ERR_UNRECOGNIZED_FTP_DIRECTORY_LISTING_FORMAT = -334;
constexpr int32_t ERR_NO_SUPPORTED_PROXIES = -336;
constexpr int32_t ERR_HTTP2_PROTOCOL_ERROR = -337;
constexpr int32_t ERR_INVALID_AUTH_CREDENTIALS = -338;
constexpr int32_t ERR_UNSUPPORTED_AUTH_SCHEME = -339;
constexpr int32_t ERR_ENCODING_DETECTION_FAILED = -340;
constexpr int32_t ERR_MISSING_AUTH_CREDENTIALS = -341;
constexpr int32_t ERR_UNEXPECTED_SECURITY_LIBRARY_STATUS = -342;
constexpr int32_t ERR_MISCONFIGURED_AUTH_ENVIRONMENT = -343;
constexpr int32_t ERR_UNDOCUMENTED_SECURITY_LIBRARY_STATUS = -344;
constexpr int32_t ERR_RESPONSE_BODY_TOO_BIG_TO_DRAIN = -345;
constexpr int32_t ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_LENGTH = -346;
constexpr int32_t ERR_INCOMPLETE_HTTP2_HEADERS = -347;
constexpr int32_t ERR_PAC_NOT_IN_DHCP = -348;
constexpr int32_t ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION = -349;
constexpr int32_t ERR_RESPONSE_HEADERS_MULTIPLE_LOCATION = -350;
constexpr int32_t ERR_HTTP2_SERVER_REFUSED_STREAM = -351;
constexpr int32_t ERR_HTTP2_PING_FAILED = -352;
constexpr int32_t ERR_CONTENT_LENGTH_MISMATCH = -354;
constexpr int32_t ERR_INCOMPLETE_CHUNKED_ENCODING = -355;
constexpr int32_t ERR_QUIC_PROTOCOL_ERROR = -356;
constexpr int32_t ERR_RESPONSE_HEADERS_TRUNCATED = -357;
constexpr int32_t ERR_QUIC_HANDSHAKE_FAILED = -358;
constexpr int32_t ERR_HTTP2_INADEQUATE_TRANSPORT_SECURITY = -360;
constexpr int32_t ERR_HTTP2_FLOW_CONTROL_ERROR = -361;
constexpr int32_t ERR_HTTP2_FRAME_SIZE_ERROR = -362;
constexpr int32_t ERR_HTTP2_COMPRESSION_ERROR = -363;
constexpr int32_t ERR_PROXY_AUTH_REQUESTED_WITH_NO_CONNECTION = -364;
constexpr int32_t ERR_HTTP_1_1_REQUIRED = -365;
constexpr int32_t ERR_PROXY_HTTP_1_1_REQUIRED = -366;
constexpr int32_t ERR_PAC_SCRIPT_TERMINATED = -367;
constexpr int32_t ERR_INVALID_HTTP_RESPONSE = -370;
constexpr int32_t ERR_CONTENT_DECODING_INIT_FAILED = -371;
constexpr int32_t ERR_HTTP2_RST_STREAM_NO_ERROR_RECEIVED = -372;
constexpr int32_t ERR_HTTP2_PUSHED_STREAM_NOT_AVAILABLE = -373;
constexpr int32_t ERR_HTTP2_CLAIMED_PUSHED_STREAM_RESET_BY_SERVER = -374;
constexpr int32_t ERR_TOO_MANY_RETRIES = -375;
constexpr int32_t ERR_HTTP2_STREAM_CLOSED = -376;
constexpr int32_t ERR_HTTP2_CLIENT_REFUSED_STREAM = -377;
constexpr int32_t ERR_HTTP2_PUSHED_RESPONSE_DOES_NOT_MATCH = -378;
constexpr int32_t ERR_HTTP_RESPONSE_CODE_FAILURE = -379;
constexpr int32_t ERR_QUIC_UNKNOWN_CERT_ROOT = -380;
constexpr int32_t ERR_QUIC_GOAWAY_REQUEST_CAN_BE_RETRIED = -381;
constexpr int32_t ERR_TOO_MANY_ACCEPT_CH_RESTARTS = -382;
constexpr int32_t ERR_INCONSISTENT_IP_ADDRESS_SPACE = -383;
constexpr int32_t ERR_CACHED_IP_ADDRESS_SPACE_BLOCKED_BY_LOCAL_NETWORK_ACCESS_POLICY = -384;
constexpr int32_t ERR_CACHE_MISS = -400;
constexpr int32_t ERR_CACHE_READ_FAILURE = -401;
constexpr int32_t ERR_CACHE_WRITE_FAILURE = -402;
constexpr int32_t ERR_CACHE_OPERATION_UNSUPPORTED = -403;
constexpr int32_t ERR_CACHE_OPEN_FAILURE = -404;
constexpr int32_t ERR_CACHE_CREATE_FAILURE = -405;
constexpr int32_t ERR_CACHE_RACE = -406;
constexpr int32_t ERR_CACHE_CHECKSUM_READ_FAILURE = -407;
constexpr int32_t ERR_CACHE_CHECKSUM_MISMATCH = -408;
constexpr int32_t ERR_CACHE_LOCK_TIMEOUT = -409;
constexpr int32_t ERR_CACHE_AUTH_FAILURE_AFTER_READ = -410;
constexpr int32_t ERR_CACHE_ENTRY_NOT_SUITABLE = -411;
constexpr int32_t ERR_CACHE_DOOM_FAILURE = -412;
constexpr int32_t ERR_CACHE_OPEN_OR_CREATE_FAILURE = -413;
constexpr int32_t ERR_INSECURE_RESPONSE = -501;
constexpr int32_t ERR_NO_PRIVATE_KEY_FOR_CERT = -502;
constexpr int32_t ERR_ADD_USER_CERT_FAILED = -503;
constexpr int32_t ERR_INVALID_SIGNED_EXCHANGE = -504;
constexpr int32_t ERR_INVALID_WEB_BUNDLE = -505;
constexpr int32_t ERR_TRUST_TOKEN_OPERATION_FAILED = -506;
constexpr int32_t ERR_TRUST_TOKEN_OPERATION_SUCCESS_WITHOUT_SENDING_REQUEST = -507;
constexpr int32_t ERR_FTP_FAILED = -601;
constexpr int32_t ERR_FTP_SERVICE_UNAVAILABLE = -602;
constexpr int32_t ERR_FTP_TRANSFER_ABORTED = -603;
constexpr int32_t ERR_FTP_FILE_BUSY = -604;
constexpr int32_t ERR_FTP_SYNTAX_ERROR = -605;
constexpr int32_t ERR_FTP_COMMAND_UNSUPPORTED = -606;
constexpr int32_t ERR_FTP_BAD_COMMAND_SEQUENCE = -607;
constexpr int32_t ERR_PKCS12_IMPORT_BAD_PASSWORD = -701;
constexpr int32_t ERR_PKCS12_IMPORT_FAILED = -702;
constexpr int32_t ERR_IMPORT_CA_CERT_NOT_CA = -703;
constexpr int32_t ERR_IMPORT_CERT_ALREADY_EXISTS = -704;
constexpr int32_t ERR_IMPORT_CA_CERT_FAILED = -705;
constexpr int32_t ERR_IMPORT_SERVER_CERT_FAILED = -706;
constexpr int32_t ERR_PKCS12_IMPORT_INVALID_MAC = -707;
constexpr int32_t ERR_PKCS12_IMPORT_INVALID_FILE = -708;
constexpr int32_t ERR_PKCS12_IMPORT_UNSUPPORTED = -709;
constexpr int32_t ERR_KEY_GENERATION_FAILED = -710;
constexpr int32_t ERR_PRIVATE_KEY_EXPORT_FAILED = -712;
constexpr int32_t ERR_SELF_SIGNED_CERT_GENERATION_FAILED = -713;
constexpr int32_t ERR_CERT_DATABASE_CHANGED = -714;
constexpr int32_t ERR_CERT_VERIFIER_CHANGED = -716;
constexpr int32_t ERR_DNS_MALFORMED_RESPONSE = -800;
constexpr int32_t ERR_DNS_SERVER_REQUIRES_TCP = -801;
constexpr int32_t ERR_DNS_SERVER_FAILED = -802;
constexpr int32_t ERR_DNS_TIMED_OUT = -803;
constexpr int32_t ERR_DNS_CACHE_MISS = -804;
constexpr int32_t ERR_DNS_SEARCH_EMPTY = -805;
constexpr int32_t ERR_DNS_SORT_ERROR = -806;
constexpr int32_t ERR_DNS_SECURE_RESOLVER_HOSTNAME_RESOLUTION_FAILED = -808;
constexpr int32_t ERR_DNS_NAME_HTTPS_ONLY = -809;
constexpr int32_t ERR_DNS_REQUEST_CANCELED = -810;
constexpr int32_t ERR_DNS_NO_MATCHING_SUPPORTED_ALPN = -811;

const std::unordered_map<int32_t, int32_t>& GetErrorMap()
{
    static const auto errorMap = [] {
        const std::vector<int32_t> codes = {
            NET_OK,
            ERR_IO_PENDING,
            ERR_FAILED,
            ERR_ABORTED,
            ERR_INVALID_ARGUMENT,
            ERR_INVALID_HANDLE,
            ERR_FILE_NOT_FOUND,
            ERR_TIMED_OUT,
            ERR_FILE_TOO_LARGE,
            ERR_UNEXPECTED,
            ERR_ACCESS_DENIED,
            ERR_NOT_IMPLEMENTED,
            ERR_INSUFFICIENT_RESOURCES,
            ERR_OUT_OF_MEMORY,
            ERR_UPLOAD_FILE_CHANGED,
            ERR_SOCKET_NOT_CONNECTED,
            ERR_FILE_EXISTS,
            ERR_FILE_PATH_TOO_LONG,
            ERR_FILE_NO_SPACE,
            ERR_FILE_VIRUS_INFECTED,
            ERR_BLOCKED_BY_CLIENT,
            ERR_NETWORK_CHANGED,
            ERR_BLOCKED_BY_ADMINISTRATOR,
            ERR_SOCKET_CONNECTED,
            ERR_UPLOAD_STREAM_REWIND_NOT_SUPPORTED,
            ERR_CONTEXT_SHUT_DOWN,
            ERR_BLOCKED_BY_RESPONSE,
            ERR_CLEARTEXT_NOT_PERMITTED,
            ERR_BLOCKED_BY_CSP,
            ERR_H2_OR_QUIC_REQUIRED,
            ERR_BLOCKED_BY_ORB,
            ERR_CONNECTION_CLOSED,
            ERR_CONNECTION_RESET,
            ERR_CONNECTION_REFUSED,
            ERR_CONNECTION_ABORTED,
            ERR_CONNECTION_FAILED,
            ERR_NAME_NOT_RESOLVED,
            ERR_INTERNET_DISCONNECTED,
            ERR_SSL_PROTOCOL_ERROR,
            ERR_ADDRESS_INVALID,
            ERR_ADDRESS_UNREACHABLE,
            ERR_SSL_CLIENT_AUTH_CERT_NEEDED,
            ERR_TUNNEL_CONNECTION_FAILED,
            ERR_NO_SSL_VERSIONS_ENABLED,
            ERR_SSL_VERSION_OR_CIPHER_MISMATCH,
            ERR_SSL_RENEGOTIATION_REQUESTED,
            ERR_PROXY_AUTH_UNSUPPORTED,
            ERR_BAD_SSL_CLIENT_AUTH_CERT,
            ERR_CONNECTION_TIMED_OUT,
            ERR_HOST_RESOLVER_QUEUE_TOO_LARGE,
            ERR_SOCKS_CONNECTION_FAILED,
            ERR_SOCKS_CONNECTION_HOST_UNREACHABLE,
            ERR_ALPN_NEGOTIATION_FAILED,
            ERR_SSL_NO_RENEGOTIATION,
            ERR_WINSOCK_UNEXPECTED_WRITTEN_BYTES,
            ERR_SSL_DECOMPRESSION_FAILURE_ALERT,
            ERR_SSL_BAD_RECORD_MAC_ALERT,
            ERR_PROXY_AUTH_REQUESTED,
            ERR_PROXY_CONNECTION_FAILED,
            ERR_MANDATORY_PROXY_CONFIGURATION_FAILED,
            ERR_PRECONNECT_MAX_SOCKET_LIMIT,
            ERR_SSL_CLIENT_AUTH_PRIVATE_KEY_ACCESS_DENIED,
            ERR_SSL_CLIENT_AUTH_CERT_NO_PRIVATE_KEY,
            ERR_PROXY_CERTIFICATE_INVALID,
            ERR_NAME_RESOLUTION_FAILED,
            ERR_NETWORK_ACCESS_DENIED,
            ERR_TEMPORARILY_THROTTLED,
            ERR_HTTPS_PROXY_TUNNEL_RESPONSE_REDIRECT,
            ERR_SSL_CLIENT_AUTH_SIGNATURE_FAILED,
            ERR_MSG_TOO_BIG,
            ERR_WS_PROTOCOL_ERROR,
            ERR_ADDRESS_IN_USE,
            ERR_SSL_HANDSHAKE_NOT_COMPLETED,
            ERR_SSL_BAD_PEER_PUBLIC_KEY,
            ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN,
            ERR_CLIENT_AUTH_CERT_TYPE_UNSUPPORTED,
            ERR_SSL_DECRYPT_ERROR_ALERT,
            ERR_WS_THROTTLE_QUEUE_TOO_LARGE,
            ERR_SSL_SERVER_CERT_CHANGED,
            ERR_SSL_UNRECOGNIZED_NAME_ALERT,
            ERR_SOCKET_SET_RECEIVE_BUFFER_SIZE_ERROR,
            ERR_SOCKET_SET_SEND_BUFFER_SIZE_ERROR,
            ERR_SOCKET_RECEIVE_BUFFER_SIZE_UNCHANGEABLE,
            ERR_SOCKET_SEND_BUFFER_SIZE_UNCHANGEABLE,
            ERR_SSL_CLIENT_AUTH_CERT_BAD_FORMAT,
            ERR_ICANN_NAME_COLLISION,
            ERR_SSL_SERVER_CERT_BAD_FORMAT,
            ERR_CT_STH_PARSING_FAILED,
            ERR_CT_STH_INCOMPLETE,
            ERR_UNABLE_TO_REUSE_CONNECTION_FOR_PROXY_AUTH,
            ERR_CT_CONSISTENCY_PROOF_PARSING_FAILED,
            ERR_SSL_OBSOLETE_CIPHER,
            ERR_WS_UPGRADE,
            ERR_READ_IF_READY_NOT_IMPLEMENTED,
            ERR_NO_BUFFER_SPACE,
            ERR_SSL_CLIENT_AUTH_NO_COMMON_ALGORITHMS,
            ERR_EARLY_DATA_REJECTED,
            ERR_WRONG_VERSION_ON_EARLY_DATA,
            ERR_TLS13_DOWNGRADE_DETECTED,
            ERR_SSL_KEY_USAGE_INCOMPATIBLE,
            ERR_INVALID_ECH_CONFIG_LIST,
            ERR_ECH_NOT_NEGOTIATED,
            ERR_ECH_FALLBACK_CERTIFICATE_INVALID,
            ERR_CERT_COMMON_NAME_INVALID,
            ERR_CERT_DATE_INVALID,
            ERR_CERT_AUTHORITY_INVALID,
            ERR_CERT_CONTAINS_ERRORS,
            ERR_CERT_NO_REVOCATION_MECHANISM,
            ERR_CERT_UNABLE_TO_CHECK_REVOCATION,
            ERR_CERT_REVOKED,
            ERR_CERT_INVALID,
            ERR_CERT_WEAK_SIGNATURE_ALGORITHM,
            ERR_CERT_NON_UNIQUE_NAME,
            ERR_CERT_WEAK_KEY,
            ERR_CERT_NAME_CONSTRAINT_VIOLATION,
            ERR_CERT_VALIDITY_TOO_LONG,
            ERR_CERTIFICATE_TRANSPARENCY_REQUIRED,
            ERR_CERT_SYMANTEC_LEGACY,
            ERR_CERT_KNOWN_INTERCEPTION_BLOCKED,
            ERR_SSL_OBSOLETE_VERSION_OR_CIPHER,
            ERR_CERT_END,
            ERR_INVALID_URL,
            ERR_DISALLOWED_URL_SCHEME,
            ERR_UNKNOWN_URL_SCHEME,
            ERR_INVALID_REDIRECT,
            ERR_TOO_MANY_REDIRECTS,
            ERR_UNSAFE_REDIRECT,
            ERR_UNSAFE_PORT,
            ERR_INVALID_RESPONSE,
            ERR_INVALID_CHUNKED_ENCODING,
            ERR_METHOD_UNSUPPORTED,
            ERR_UNEXPECTED_PROXY_AUTH,
            ERR_EMPTY_RESPONSE,
            ERR_RESPONSE_HEADERS_TOO_BIG,
            ERR_PAC_SCRIPT_FAILED,
            ERR_REQUEST_RANGE_NOT_SATISFIABLE,
            ERR_MALFORMED_IDENTITY,
            ERR_CONTENT_DECODING_FAILED,
            ERR_NETWORK_IO_SUSPENDED,
            ERR_SYN_REPLY_NOT_RECEIVED,
            ERR_ENCODING_CONVERSION_FAILED,
            ERR_UNRECOGNIZED_FTP_DIRECTORY_LISTING_FORMAT,
            ERR_NO_SUPPORTED_PROXIES,
            ERR_HTTP2_PROTOCOL_ERROR,
            ERR_INVALID_AUTH_CREDENTIALS,
            ERR_UNSUPPORTED_AUTH_SCHEME,
            ERR_ENCODING_DETECTION_FAILED,
            ERR_MISSING_AUTH_CREDENTIALS,
            ERR_UNEXPECTED_SECURITY_LIBRARY_STATUS,
            ERR_MISCONFIGURED_AUTH_ENVIRONMENT,
            ERR_UNDOCUMENTED_SECURITY_LIBRARY_STATUS,
            ERR_RESPONSE_BODY_TOO_BIG_TO_DRAIN,
            ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_LENGTH,
            ERR_INCOMPLETE_HTTP2_HEADERS,
            ERR_PAC_NOT_IN_DHCP,
            ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION,
            ERR_RESPONSE_HEADERS_MULTIPLE_LOCATION,
            ERR_HTTP2_SERVER_REFUSED_STREAM,
            ERR_HTTP2_PING_FAILED,
            ERR_CONTENT_LENGTH_MISMATCH,
            ERR_INCOMPLETE_CHUNKED_ENCODING,
            ERR_QUIC_PROTOCOL_ERROR,
            ERR_RESPONSE_HEADERS_TRUNCATED,
            ERR_QUIC_HANDSHAKE_FAILED,
            ERR_HTTP2_INADEQUATE_TRANSPORT_SECURITY,
            ERR_HTTP2_FLOW_CONTROL_ERROR,
            ERR_HTTP2_FRAME_SIZE_ERROR,
            ERR_HTTP2_COMPRESSION_ERROR,
            ERR_PROXY_AUTH_REQUESTED_WITH_NO_CONNECTION,
            ERR_HTTP_1_1_REQUIRED,
            ERR_PROXY_HTTP_1_1_REQUIRED,
            ERR_PAC_SCRIPT_TERMINATED,
            ERR_INVALID_HTTP_RESPONSE,
            ERR_CONTENT_DECODING_INIT_FAILED,
            ERR_HTTP2_RST_STREAM_NO_ERROR_RECEIVED,
            ERR_HTTP2_PUSHED_STREAM_NOT_AVAILABLE,
            ERR_HTTP2_CLAIMED_PUSHED_STREAM_RESET_BY_SERVER,
            ERR_TOO_MANY_RETRIES,
            ERR_HTTP2_STREAM_CLOSED,
            ERR_HTTP2_CLIENT_REFUSED_STREAM,
            ERR_HTTP2_PUSHED_RESPONSE_DOES_NOT_MATCH,
            ERR_HTTP_RESPONSE_CODE_FAILURE,
            ERR_QUIC_UNKNOWN_CERT_ROOT,
            ERR_QUIC_GOAWAY_REQUEST_CAN_BE_RETRIED,
            ERR_TOO_MANY_ACCEPT_CH_RESTARTS,
            ERR_INCONSISTENT_IP_ADDRESS_SPACE,
            ERR_CACHED_IP_ADDRESS_SPACE_BLOCKED_BY_LOCAL_NETWORK_ACCESS_POLICY,
            ERR_CACHE_MISS,
            ERR_CACHE_READ_FAILURE,
            ERR_CACHE_WRITE_FAILURE,
            ERR_CACHE_OPERATION_UNSUPPORTED,
            ERR_CACHE_OPEN_FAILURE,
            ERR_CACHE_CREATE_FAILURE,
            ERR_CACHE_RACE,
            ERR_CACHE_CHECKSUM_READ_FAILURE,
            ERR_CACHE_CHECKSUM_MISMATCH,
            ERR_CACHE_LOCK_TIMEOUT,
            ERR_CACHE_AUTH_FAILURE_AFTER_READ,
            ERR_CACHE_ENTRY_NOT_SUITABLE,
            ERR_CACHE_DOOM_FAILURE,
            ERR_CACHE_OPEN_OR_CREATE_FAILURE,
            ERR_INSECURE_RESPONSE,
            ERR_NO_PRIVATE_KEY_FOR_CERT,
            ERR_ADD_USER_CERT_FAILED,
            ERR_INVALID_SIGNED_EXCHANGE,
            ERR_INVALID_WEB_BUNDLE,
            ERR_TRUST_TOKEN_OPERATION_FAILED,
            ERR_TRUST_TOKEN_OPERATION_SUCCESS_WITHOUT_SENDING_REQUEST,
            ERR_FTP_FAILED,
            ERR_FTP_SERVICE_UNAVAILABLE,
            ERR_FTP_TRANSFER_ABORTED,
            ERR_FTP_FILE_BUSY,
            ERR_FTP_SYNTAX_ERROR,
            ERR_FTP_COMMAND_UNSUPPORTED,
            ERR_FTP_BAD_COMMAND_SEQUENCE,
            ERR_PKCS12_IMPORT_BAD_PASSWORD,
            ERR_PKCS12_IMPORT_FAILED,
            ERR_IMPORT_CA_CERT_NOT_CA,
            ERR_IMPORT_CERT_ALREADY_EXISTS,
            ERR_IMPORT_CA_CERT_FAILED,
            ERR_IMPORT_SERVER_CERT_FAILED,
            ERR_PKCS12_IMPORT_INVALID_MAC,
            ERR_PKCS12_IMPORT_INVALID_FILE,
            ERR_PKCS12_IMPORT_UNSUPPORTED,
            ERR_KEY_GENERATION_FAILED,
            ERR_PRIVATE_KEY_EXPORT_FAILED,
            ERR_SELF_SIGNED_CERT_GENERATION_FAILED,
            ERR_CERT_DATABASE_CHANGED,
            ERR_CERT_VERIFIER_CHANGED,
            ERR_DNS_MALFORMED_RESPONSE,
            ERR_DNS_SERVER_REQUIRES_TCP,
            ERR_DNS_SERVER_FAILED,
            ERR_DNS_TIMED_OUT,
            ERR_DNS_CACHE_MISS,
            ERR_DNS_SEARCH_EMPTY,
            ERR_DNS_SORT_ERROR,
            ERR_DNS_SECURE_RESOLVER_HOSTNAME_RESOLUTION_FAILED,
            ERR_DNS_NAME_HTTPS_ONLY,
            ERR_DNS_REQUEST_CANCELED,
            ERR_DNS_NO_MATCHING_SUPPORTED_ALPN,
        };

        std::unordered_map<int32_t, int32_t> map;
        map.reserve(codes.size());
        for (size_t i = 0; i < codes.size(); ++i) {
            map[codes[i]] = static_cast<int32_t>(i);
        }
        return map;
    }();
    return errorMap;
}

int32_t GetErrorIndex(int32_t errorCode)
{
    const auto& map = GetErrorMap();
    try {
        return map.at(errorCode);
    } catch (const std::out_of_range&) {
        return -1;
    }
}
} // namespace NWeb
} // namespace OHOS
#endif